﻿using System;
using System.Data;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyWeb.Business;

namespace MyWeb.TrangChinh.UC
{
    public partial class ucListProduct : UserControl
    {
        private readonly GroupProductService _groupProductService = new GroupProductService();
        private readonly ProductService _productService = new ProductService();
     
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int idGr = Int32.Parse(Request.QueryString["idGroupProduct"]);
                DataTable tableProductName = _groupProductService.GroupProduct_GetById(idGr);
                lblHeader.Text = string.Format(tableProductName.Rows[0]["Name"] + " >>").ToUpper();
                DataTable tableProduct = _productService.Product_GetByGroupProductId(idGr);
                rptProduct.DataSource = tableProduct;
                rptProduct.DataBind();
            }
        }

        protected void rptProduct_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string id = e.CommandArgument.ToString();
            if (e.CommandName == "Image")
            {
                Response.Redirect("~/TrangChinh/Product.aspx?idProduct=" + id);
            }
        }
    }
}